eeprom15 2.2.1
Loading...
Searching...
No Matches
eeprom15.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2026 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
27
28#ifndef EEPROM15_H
29#define EEPROM15_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
58
63
68
73#define EEPROM15_REG_RW_EE_MEMORY 0x50
74#define EEPROM15_REG_RW_WP_BLOCK_0 0x31
75#define EEPROM15_REG_RW_WP_BLOCK_1 0x34
76#define EEPROM15_REG_RW_WP_BLOCK_2 0x35
77#define EEPROM15_REG_RW_WP_BLOCK_3 0x30
78#define EEPROM15_REG_CLEAR_ALL_WP 0x33
79#define EEPROM15_REG_SET_PAGE_ADDR_0 0x36
80#define EEPROM15_REG_SET_PAGE_ADDR_1 0x37
81#define EEPROM15_REG_READ_PAGE_ADDR 0x36
82 // eeprom15_reg
84
89
94
99#define EEPROM15_MEM_PAGE_BITMASK 0xF0
100#define EEPROM15_MEM_PAGE_SIZE 16
101#define EEPROM15_MEM_BANK_SIZE 256
102
107#define EEPROM15_BANK_SEL_0 0x00
108#define EEPROM15_BANK_SEL_1 0x01
109
114#define EEPROM15_WP_BLOCK_SEL_0 0x00
115#define EEPROM15_WP_BLOCK_SEL_1 0x01
116#define EEPROM15_WP_BLOCK_SEL_2 0x02
117#define EEPROM15_WP_BLOCK_SEL_3 0x03
118
124#define EEPROM15_ADDRESS_A2A1A0_000 0x00
125#define EEPROM15_ADDRESS_A2A1A0_001 0x01
126#define EEPROM15_ADDRESS_A2A1A0_010 0x02
127#define EEPROM15_ADDRESS_A2A1A0_011 0x03
128#define EEPROM15_ADDRESS_A2A1A0_100 0x04
129#define EEPROM15_ADDRESS_A2A1A0_101 0x05
130#define EEPROM15_ADDRESS_A2A1A0_110 0x06
131#define EEPROM15_ADDRESS_A2A1A0_111 0x07
132 // eeprom15_set
134
139
144
149#define EEPROM15_MAP_MIKROBUS( cfg, mikrobus ) \
150 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
151 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
152 cfg.wp = MIKROBUS( mikrobus, MIKROBUS_PWM );
153 // eeprom15_map // eeprom15
156
161typedef struct
162{
163 // Output pins
164 digital_out_t wp;
165
166 // Modules
167 i2c_master_t i2c;
168
169 // I2C slave address
171
172} eeprom15_t;
173
178typedef struct
179{
180 pin_name_t scl;
181 pin_name_t sda;
182
183 pin_name_t wp;
184
185 uint32_t i2c_speed;
186 uint8_t i2c_address;
187
189
194typedef enum
195{
198
200
206
217
232
245err_t eeprom15_write_memory ( eeprom15_t *ctx, uint8_t address, uint8_t *data_in, uint8_t len );
246
259err_t eeprom15_read_memory ( eeprom15_t *ctx, uint8_t address, uint8_t *data_out, uint16_t len );
260
269void eeprom15_set_wp_pin ( eeprom15_t *ctx, uint8_t state );
270
281err_t eeprom15_select_bank ( eeprom15_t *ctx, uint8_t bank_sel );
282
293err_t eeprom15_set_wp_block ( eeprom15_t *ctx, uint8_t block_num );
294
305
306#ifdef __cplusplus
307}
308#endif
309#endif // EEPROM15_H
310 // eeprom15
312
313// ------------------------------------------------------------------------ END
eeprom15_return_value_t
EEPROM 15 Click return value data.
Definition eeprom15.h:195
@ EEPROM15_ERROR
Definition eeprom15.h:197
@ EEPROM15_OK
Definition eeprom15.h:196
err_t eeprom15_set_wp_block(eeprom15_t *ctx, uint8_t block_num)
EEPROM 15 Set Write Protection Block function.
err_t eeprom15_write_memory(eeprom15_t *ctx, uint8_t address, uint8_t *data_in, uint8_t len)
EEPROM 15 Write Memory function.
err_t eeprom15_read_memory(eeprom15_t *ctx, uint8_t address, uint8_t *data_out, uint16_t len)
EEPROM 15 Read Memory function.
err_t eeprom15_init(eeprom15_t *ctx, eeprom15_cfg_t *cfg)
EEPROM 15 initialization function.
void eeprom15_cfg_setup(eeprom15_cfg_t *cfg)
EEPROM 15 configuration object setup function.
err_t eeprom15_select_bank(eeprom15_t *ctx, uint8_t bank_sel)
EEPROM 15 Select Memory Bank function.
err_t eeprom15_clear_wp(eeprom15_t *ctx)
EEPROM 15 Clear Write Protection function.
void eeprom15_set_wp_pin(eeprom15_t *ctx, uint8_t state)
EEPROM 15 Set Write Protection Pin function.
EEPROM 15 Click configuration object.
Definition eeprom15.h:179
uint32_t i2c_speed
Definition eeprom15.h:185
pin_name_t wp
Definition eeprom15.h:183
pin_name_t scl
Definition eeprom15.h:180
pin_name_t sda
Definition eeprom15.h:181
uint8_t i2c_address
Definition eeprom15.h:186
EEPROM 15 Click context object.
Definition eeprom15.h:162
i2c_master_t i2c
Definition eeprom15.h:167
uint8_t slave_address
Definition eeprom15.h:170
digital_out_t wp
Definition eeprom15.h:164